package com.dog.basics.admin.controller.common;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.admin.common.AdminUserConnectEditDto;
import com.dog.basics.bean.dto.admin.common.AdminUserConnectPageDto;
import com.dog.basics.bean.vo.admin.common.AdminUserConnectPageVo;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.service.common.DogUserConnectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/***
 * 账户控制
 * guonh 2021年7月23日
 */
@RestController
@AllArgsConstructor
@RequestMapping("/admin/connect")
@Api(value = "金额扣除", tags = "金额扣除")
public class AdminUserConnectController {

    private final DogUserConnectService userConnectService;

    /**
     * 账户余额分页
     * guonh 2021年7月23日
     */
    @ApiOperation(value = "账户余额分页",notes = "admin_connect_page")
    @GetMapping
    @PreAuthorize("@pms.hasPermission('admin_connect_page')")
    public R<IPage<AdminUserConnectPageVo>> getAdminUserConnectPage(PageParam param, AdminUserConnectPageDto dto){
        return R.ok(userConnectService.getAdminUserConnectPage(param, dto));
    }


    /**
     * 账户金额扣除
     * guonh 2021年7月23日
     */
    @ApiOperation(value = "账户金额扣除",notes = "admin_connect_edit")
    @PutMapping
    @PreAuthorize("@pms.hasPermission('admin_connect_edit')")
    public R<Boolean> putAdminUserConnectEdit(@RequestBody AdminUserConnectEditDto dto){
        return R.ok(userConnectService.putAdminUserConnectEdit(dto));
    }

}
